
package ch.hearc.coursJava.GUI.frame.compteurBis;

import java.awt.FlowLayout;

import javax.swing.JComponent;
import javax.swing.JFrame;

public abstract class JFrameCommon extends JFrame
	{

	/*------------------------------------------------------------------*\
	|*							Constructeurs							*|
	\*------------------------------------------------------------------*/

	public JFrameCommon(String title, int n, LiaisonLabelButton[] tabLiaisonLabelButton)
		{
		this.tabLiaisonLabelButton = tabLiaisonLabelButton;

		creerComposant(n);
		addComposant();
		setPropriete(title);
		}

	/*------------------------------------------------------------------*\
	|*							Methodes Abstract						*|
	\*------------------------------------------------------------------*/

	protected abstract JComponent createComponent(int i, LiaisonLabelButton liaisonLabelButton);

	/*------------------------------------------------------------------*\
	|*							Methodes Public							*|
	\*------------------------------------------------------------------*/

	/*------------------------------------------------------------------*\
	|*							Methodes Private						*|
	\*------------------------------------------------------------------*/

	private void setPropriete(String title)
		{
		this.setTitle(title);
		this.setSize(250, 150);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setVisible(true);
		}

	private void addComposant()
		{
		this.setLayout(new FlowLayout());
		for(JComponent component:tabComponent)
			{
			this.add(component);
			}
		}

	private void creerComposant(int n)
		{
		tabComponent = new JComponent[n];
		for(int i = 1; i <= n; i++)
			{
			tabComponent[i - 1] = createComponent(i, tabLiaisonLabelButton[i - 1]);
			}
		}

	/*------------------------------------------------------------------*\
	|*							Attributs Private						*|
	\*------------------------------------------------------------------*/

	// Tools
	private JComponent[] tabComponent;

	// Input
	private LiaisonLabelButton[] tabLiaisonLabelButton;

	}
